﻿function add5() {
    for (var i = 0; i < 3; i++) {
        addFiled();
    }
}
function addFiled() {
    var tbl = document.getElementById("tb1");
    var rid = "txt_row_" + tbl.rows.length;
    var row = tbl.insertRow(tbl.rows.length);
    var cell0 = row.insertCell(0);
    var cell1 = row.insertCell(1);
    var cell2 = row.insertCell(2);
    var cell3 = row.insertCell(3);
    var cell4 = row.insertCell(4);
    var cell5 = row.insertCell(5);
    var cell6 = row.insertCell(6);
    var cell7 = row.insertCell(7);
    var cell8 = row.insertCell(8);
    cell0.innerHTML = " <input type=\"text\" class=\"txtwidth\"  name=\"txtCode\" id=\"" + rid + "_" + "txt1" + "\"/>";
    cell1.innerHTML = "<input type=\"text\" name=\"txtName\"  id=\"" + rid + "_" + "txt2" + "\"/>";
    cell2.innerHTML = " <input type=\"text\" class=\"txtwidth\"  name=\"txtPoint\" onkeydown=\"myKeyDown()\" id=\"" + rid + "_" + "txt3" + "\"/>";
    cell3.innerHTML = "<input type=\"text\" name=\"txtRemark\"  />";
    cell4.innerHTML = "<input type=\"text\" name=\"txtNum\" onkeydown=\"myKeyDown()\" />";
    cell5.innerHTML = " <input type=\"text\" class=\"txtwidth\"  name=\"txtUnit\"  />"
    cell6.innerHTML = " <input type=\"text\" class=\"txtwidth\"  name=\"txtHighest\" onkeydown=\"myKeyDown()\" />";
    cell7.innerHTML = " <input type=\"text\" class=\"txtwidth\"  name=\"txtSort\" onkeydown=\"myKeyDown()\" />";
    cell8.innerHTML = " <input    type='button'  value='删除' onclick=\"delRow(this,'tb1')\" />";
    //cell6.innerHTML = " <input name=\"ckDe\" type=\"checkbox\"  class=\"txtwidth\"   />";
}
function delRow(row, tbname) {
    var tbl = document.getElementById(tbname);
    var rowIndex = row.parentNode.parentNode.rowIndex;
    tbl.deleteRow(rowIndex);
}
function myKeyDown() {
    var k = window.event.keyCode;
    if ((k == 46) || (k == 8) || (k == 189) || (k == 109) || (k == 190) || (k == 110) || (k >= 48 && k <= 57) || (k >= 96 && k <= 105) || (k >= 37 && k <= 40))
    { }
    else if (k == 13) {
        window.event.keyCode = 9;
    }
    else {
        window.event.returnValue = false;
    }
}